package com.creditcmsplt.util;

import java.util.Random;


/**
 * 随机字符串生成器
 * @author Administrator
 *
 */
public class RandomUtil {

	/**
	 * 产生a-b包含大小写,0-9的随机字符
	 * @param length
	 * @return
	 */
	public static String randomString(int length) {  
	    String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";  
	    Random random = new Random();  
	    StringBuffer buf = new StringBuffer();  
	    for (int i = 0; i < length; i++) {  
	        int num = random.nextInt(62);  
	        buf.append(str.charAt(num));
	    }
	    return buf.toString();  
	}  
	
	public static void main(String[] args) {
		System.out.println(randomString(15));
		
		System.out.println(randomString(32));
	}
	
}
